import * as axiosService from './axiosInstance.js'
import qs from 'qs'

const $apiService = {
    customApi(url, data) {
        // const url = `/api/auth/oauth/token`
        return axiosService.postAction(url, data)
    },
    // +----------------------------------------------------------------------------------------------
    // | 登录页面
    // +----------------------------------------------------------------------------------------------
    handshake() {
        const url = `/api/epms/handshake`
        return axiosService.postAction(url, {})
    },
    tenantViewQueryMyByCode(param) { // 未登录时, 根据租户code获取信息
        const url = `/api/user/TenantView.queryMyByCode.query`
        return axiosService.postAction(url, param)
    },
    tenantViewQueryOneById(param) { // 已登录时, 根据租户id获取信息
        const url = `/api/user/TenantView.queryOne.query`
        return axiosService.postAction(url, param)
    },
    // 获取当前租户信息，无需传参数
    tenantViewQueryMy(param) { // 已登录时, 获取信息
        const url = `/api/user/TenantView.queryMy.query`
        return axiosService.postAction(url, param)
    },
    loginCaptcha(s) {
        const url = `/api/auth/oauth/token.captcha?s=` + s
        // return axiosService.postAction(url, JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' }})
        return axiosService.getAction(url, {
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        })
    },
    // 登录
    login(data) {
        const url = `/api/auth/oauth/token`
        // return axiosService.postAction(url, JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' }})
        return axiosService.postAction(url, qs.stringify(data), {
            headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        })
    },
    // 大汇物联单点登录
    dahuiSSO(data) {
        const url = `/api/epms/custom-api/white/dahui/sso`
        return axiosService.postAction(url, JSON.stringify(data), {
            headers: {'Content-Type': 'application/json'},
        })
    },
    threeInfoLogin(data) {
        const url = `/api/erp-docking/login/threeLogin`
        return axiosService.postAction(url, JSON.stringify(data), {
            headers: {'Content-Type': 'application/json'},
        })
    },
    loginOut() {
        const url = `/api/auth/AuthenticationTransactor.logout.command`
        return axiosService.postAction(url, {data: {}}, {
            headers: {'Content-Type': 'application/json'},
        })
    },
    // TenantView.queryMyByCode.query

    // 获取【指定】用户信息
    getUserInfo(param) {
        const url = `/api/user/UserView.queryOneForLogin.query`
        return axiosService.postAction(url, param)
    },
    // 获取【当前】用户信息
    getMyUserInfo(param) {
        const url = `/api/user/UserView.queryOne.query`
        return axiosService.postAction(url, param)
    },
    // minio配置
    getMinioConfig(param) {
        const url = `/api/config/ConfigView.queryOne.query`
        return axiosService.postAction(url, param)
    },
    // 设置menu
    setMenuConfig(param) {
        const url = `/api/user/RoleAuthorityUITransactor.reinitialize.command`
        return axiosService.postAction(url, param)
    },
    // menu配置
    getMenuConfig(param) {
        const url = `/api/user/RoleAuthorityAppView.queryOne.query`
        return axiosService.postAction(url, param)
    },
    // 获取我的menu配置
    getMyMenuConfig() {
        const url = `/api/user/RoleAuthorityUIView.queryMyAll.query`
        const param = {
            ignoreFieldList: ['creationOperatorSnapshot', 'roleSnapshotList', 'tenantSnapshot', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 表单
    // +----------------------------------------------------------------------------------------------
    // 表单
    addForm(data) {
        // const url = `/api/epms/FormTransactor.create.command`
        const url = `/api/epms/FormTransactor.save.command`
        return axiosService.postAction(url, {data})
    },
    saveOnlineForm(data) {
        // const url = `/api/epms/FormTransactor.create.command`
        const url = `/api/epms/FormTransactor.saveOnline.command`
        return axiosService.postAction(url, {data})
    },
    editForm(data) {
        const url = `/api/epms/FormTransactor.updateInfo.command`
        return axiosService.postAction(url, {data})
    },
    getForm(id) {
        // const url = `/api/exam/form/` + formId
        const url = `/api/epms/FormView.queryOne.query`
        return axiosService.postAction(url, {params: {id}})
    },
    getFormByAutoCondition(data) {
        const url = `/api/epms/FormView.queryOne.query`
        return axiosService.postAction(url, data)
    },
    deleteForm(data) {
        const url = `/api/epms/FormTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    createViewForm(data) {
        const url = `/api/epms/FormTransactor.buildFrontViewConfig.command`
        return axiosService.postAction(url, {data})
    },
    // 获取应用列表
    getApplicationList(data) {
        const url = `/api/epms/TenantApplicationView.queryMyAllForTenant.query`
        return axiosService.postAction(url, data)
    },
    // 获取应用列表
    getTenantApplicationOne(data) {
        const url = `/api/epms/TenantApplicationView.queryOne.query`
        return axiosService.postAction(url, data)
    },
    // 获取个人应用列表
    getSelfApplicationList(data) {
        const url = `/api/epms/TenantApplicationView.queryMyAllForWorkspace.query`
        return axiosService.postAction(url, data)
    },
    // 查询单个应用
    getOneApplication(data) {
        const url = `/api/epms/ApplicationView.queryOne.query`
        return axiosService.postAction(url, data)
    },
    // 新增应用（新
    addApplication(data) {
        const url = `/api/epms/TenantApplicationTransactor.create.command`
        return axiosService.postAction(url, data)
    },
    // 修改应用(新
    updateApplication(data) {
        const url = `/api/epms/TenantApplicationTransactor.update.command`
        return axiosService.postAction(url, data)
    },
    // 删除应用
    deleteApplication(data) {
        const url = `/api/epms/ApplicationTransactor.delete.command`
        return axiosService.postAction(url, data)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - 系统信息
    // +----------------------------------------------------------------------------------------------
    // 修改系统信息
    updateSystemInfo(param) {
        const url = `/api/user/TenantTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - 账号中心
    // +----------------------------------------------------------------------------------------------
    // 【部门】列表（树形结构）
    getDepartmentAsTree(param) {
        const url = `/api/user/DepartmentView.queryTree.query`
        return axiosService.postAction(url, param)
    },
    // 【部门】列表（列表结构）
    getDepartmentAsList(param) {
        const url = `/api/user/DepartmentView.queryAll.query`
        param = {
            ...param,
            ignoreFieldList: ['creationOperatorSnapshot', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, param)
    },
    // 【部门】新增
    addDept(param) {
        const url = `/api/user/DepartmentTransactor.create.command`
        return axiosService.postAction(url, param)
    },
    // 【部门】修改
    updateDept(param) {
        const url = `/api/user/DepartmentTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // 【部门】删除
    deleteDept(param) {
        const url = `/api/user/DepartmentTransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    // 【账号】列表
    getAccountList(param) {
        const url = `/api/user/UserView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    // 【用户】列表-除fa,admin
    queryAllForBiz(param) {
        const url = `/api/user/UserView.queryAllForBiz.query`
        param = {
            ...param,
            ignoreFieldList: ['creationOperatorSnapshot', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, param)
    },
    // 【部门】通过部门id
    getDeptDataByDept(param) {
        const url = `/api/user/UserView.queryByDepart.query`
        return axiosService.postAction(url, param)
    },
    // 【账号】新增
    addAccount(param) {
        const url = `/api/user/UserTransactor.createUser.command`
        return axiosService.postAction(url, param)
    },
    // 【账号】编辑
    updateAccount(param) {
        const url = `/api/user/UserTransactor.updateUser.command`
        return axiosService.postAction(url, param)
    },
    // 【账号】删除
    deleteAccount(param) {
        const url = `/api/user/UserTransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    // 【账号】移动设备信息解绑
    unbindAccountMobileDevice(param) {
        const url = `/api/user/UserTransactor.mobileServiceUnbind.command`
        return axiosService.postAction(url, param)
    },
    // 查询所有用户
    getUserQueryAll(param) {
        const url = `/api/user/UserView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - api权限管理
    // +----------------------------------------------------------------------------------------------
    // api权限列表
    queryAuthApiList(param) {
        const url = `/api/user/RoleAuthorityApiView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - 角色管理
    // +----------------------------------------------------------------------------------------------
    // 角色列表
    getRoleList(param) {
        const url = `/api/user/RoleView.queryAll.query`
        param = {
            ignoreFieldList: ['creationOperatorSnapshot', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, param)
    },
    // 新增角色
    addRole(param) {
        const url = `/api/user/RoleTransactor.create.command`
        return axiosService.postAction(url, param)
    },
    // 修改角色
    updateRole(param) {
        const url = `/api/user/RoleTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // 查询角色下的用户
    queryListByRoleId(param) {
        const url = `/api/user/UserView.queryListByRoleId.query`
        return axiosService.postAction(url, param)
    },
    // 删除
    deleteRole(param) {
        const url = `/api/user/RoleTransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    // 获取UI权限树形结构
    getAuthorityData(param) {
        const url = `/api/user/RoleAuthorityUIView.queryAllByRole.query`
        return axiosService.postAction(url, param)
    },
    getAuthorityUiData(param) {
        const url = `/api/user/RoleAuthorityUIView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    queryMyTenantAll(param) {
        const url = `/api/user/RoleAuthorityUIView.queryMyTenantAll.query`
        return axiosService.postAction(url, param)
    },
    // 新增权限UI
    addAuthUi(param) {
        const url = `/api/user/RoleAuthorityUITransactor.create.command`
        return axiosService.postAction(url, param)
    },
    // 修改权限UI
    updateAuthUi(param) {
        const url = `/api/user/RoleAuthorityUITransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // 删除
    deleteAuthUi(param) {
        const url = `/api/user/RoleAuthorityUITransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    // 授权
    authorityRole(param) {
        const url = `/api/user/RoleTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // 获取应用授权的ID
    getAuthorityId(param) {
        const url = `/api/user/RoleAuthorityUIView.queryOneByCode.query`
        return axiosService.postAction(url, param)
    },
    // 应用授权
    authorityRoleForApp(param) {
        const url = `/api/user/RoleTransactor.updateByApp.command`
        return axiosService.postAction(url, param)
    },
    // 应用管理 - 表单授权
    authorityRoleForSheet(param) {
        const url = `/api/user/UserTransactor.editForRoleAuthorityUiIds.command`
        return axiosService.postAction(url, param)
    },
    // 应用管理 - 表单授权 - 给指定用户设置多个UI权限
    authorityRoleForManySheet(param) {
        const url = `/api/user/UserTransactor.batchEditForRoleAuthorityUiIds.command`
        return axiosService.postAction(url, param)
    },
    // 根据Ui权限id查询已经勾选人数
    queryEnableNumByUiAuthId(param) {
        const url = `/api/user/RoleAuthorityUIView.queryEnableNumByUiAuthId.query`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 组织设置 - 组织管理
    // +----------------------------------------------------------------------------------------------
    getOrgParentList(param) {
        const url = `/api/user/DepartmentChargeView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    updateCharge(param) {
        const url = `/api/user/DepartmentChargeTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    addCharge(param) {
        const url = `/api/user/DepartmentChargeTransactor.create.command`
        return axiosService.postAction(url, param)
    },
    delOrg(param) {
        const url = `/api/user/DepartmentChargeTransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    getOrgList(param) {
        const url = `/api/user/DepartmentChargeView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - 岗位管理
    // +----------------------------------------------------------------------------------------------
    // 岗位列表
    getPostList(param) {
        const url = `/api/user/PostView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    // 新增岗位
    addPost(param) {
        const url = `/api/user/PostTransactor.create.command`
        return axiosService.postAction(url, param)
    },
    // 修改岗位
    updatePost(param) {
        const url = `/api/user/PostTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // 删除
    deletePost(param) {
        const url = `/api/user/PostTransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - 职务（位）管理
    // +----------------------------------------------------------------------------------------------
    // 岗位列表
    getPositionList(param) {
        const url = `/api/user/PositionView.queryAll.query`
        return axiosService.postAction(url, param)
    },
    // 新增岗位
    addPosition(param) {
        const url = `/api/user/PositionTransactor.create.command`
        return axiosService.postAction(url, param)
    },
    // 修改岗位
    updatePosition(param) {
        const url = `/api/user/PositionTransactor.update.command`
        return axiosService.postAction(url, param)
    },
    // 删除
    deletePosition(param) {
        const url = `/api/user/PositionTransactor.delete.command`
        return axiosService.postAction(url, param)
    },
    // +----------------------------------------------------------------------------------------------
    // | 系统设置 - 个人信息
    // +----------------------------------------------------------------------------------------------
    // 个人信息查询接口
    getPersonalInfo() {
        const url = `/api/user/UserView.queryMy.query`
        const data = {
            ignoreFieldList: ['creationOperatorSnapshot', 'roleSnapshotList', 'tenantSnapshot', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, data)
    },
    // 编辑我的基本信息
    updateMyPersonalInfo(param) {
        const url = `/api/user/UserTransactor.updateMy.command`
        return axiosService.postAction(url, param)
    },
    // 编辑用户基本信息
    updatePersonalInfo(param) {
        const url = `/api/user/UserTransactor.updateUser.command`
        return axiosService.postAction(url, param)
    },
    // 个人密码修改接口
    updatePassword(param) {
        const url = `/api/user/UserTransactor.editMyCredential.command`
        return axiosService.postAction(url, param)
    },
    // 应用详情
    // 创建应用分类
    addFormCategoryTransactor(data) {
        const url = `/api/epms/FormCategoryTransactor.create.command`
        return axiosService.postAction(url, {data})
    },
    // 获取应用分类列表
    getCategoryList(id) {
        const url = `/api/epms/FormView.queryAllForTree.query`
        return axiosService.postAction(url, {params: {applicationId: id}})
    },
    // 获取应用分类列表
    getCategoryLiteList(data) {
        const url = `/api/epms/FormView.queryAllForLite.query`
        return axiosService.postAction(url, data)
    },
    // 获取应用分类剩余列表
    getCategoryListForEmpty(id) {
        const url = `/api/epms/FormCategoryView.queryAllForEmpty.query`
        return axiosService.postAction(url, {params: {applicationId: id}})
    },
    // 拖拽表单到新分类
    // FormTransactor.updateCategory.command
    updateFormCategory(data) {
        const url = `/api/epms/FormTransactor.updateCategory.command`
        return axiosService.postAction(url, {data})
    },
    updateSorts(data) {
        const url = `/api/epms/FormTransactor.updateSorts.command`
        return axiosService.postAction(url, {data})
    },
    // 修改分类名称
    editCategory(data) {
        const url = `/api/epms/FormCategoryTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    deleteCategory(data) {
        const url = `/api/epms/FormCategoryTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    // +----------------------------------------------------------------------------------------------
    // | 业务配置操作
    // +----------------------------------------------------------------------------------------------
    // 新增
    // addConfig(param) {
    //   const url = `/api/config/ConfigTransactor.create.command`
    //   return axiosService.postAction(url, param)
    // },
    // 根据id查询配置
    getConfigData(param) {
        const url = `/api/config/ConfigView.queryOne.query`
        return axiosService.postAction(url, param)
    },

    // 获取动态表单列表
    getDynamicFormList(params, type) {
        let url = `/api/form/FormDynamicView.queryAll.query`
        if (type === 'view') url = `/api/form/FormDynamicView.queryAllForPlugs.query`
        if (params.params.tableCode) {
            url += `?tableCode=${params.params.tableCode}`
        }
        return axiosService.postAction(url, params)
    },
    exportForm(params) {
        let url = `/api/form/FormDynamicView.queryAll.query.excel`
        if (params.params.tableCode) {
            url += `?tableCode=${params.params.tableCode}`
        }
        return axiosService.postAction(url, params, {
            headers: {filename: encodeURIComponent(params.attributes.fileName)},
        })
    },
    // 新增动态表单
    addDynamicForm(data) {
        let url = `/api/form/FormDynamicTransactor.create.command`
        if (data.data && data.data.tableCode) {
            url += `?tableCode=${data.data.tableCode}`
        } else if (data.tableCode) {
            url += `?tableCode=${data.tableCode}`
        }
        return axiosService.postAction(url, {data})
    },
    updataDynamicForm(data) {
        let url = `/api/form/FormDynamicTransactor.update.command`
        if (data.data && data.data.tableCode) {
            url += `?tableCode=${data.data.tableCode}`
        } else if (data.tableCode) {
            url += `?tableCode=${data.tableCode}`
        }
        return axiosService.postAction(url, {data})
    },
    deleteDynamicForm(data) {
        let url = `/api/form/FormDynamicTransactor.delete.command`
        if (data.data && data.data.tableCode) {
            url += `?tableCode=${data.data.tableCode}`
        } else if (data.tableCode) {
            url += `?tableCode=${data.tableCode}`
        }
        return axiosService.postAction(url, {data})
    },
    // 往数据表添加数据
    saveFormDynamicData(data) {
        let url = `/api/form/FormDynamicTransactor.create.command`
        if (data.id) url = `/api/form/FormDynamicTransactor.update.command`
        if (data.data && data.data.tableCode) {
            url += `?tableCode=${data.data.tableCode}`
        } else if (data.tableCode) {
            url += `?tableCode=${data.tableCode}`
        }
        return axiosService.postAction(url, {data})
    },

    updateFieldFormTransactor(data) {
        const url = `/api/epms/FieldFormTransactor.update.command`
        return axiosService.postAction(url, {data})
    },

    // 流程图
    // 查询单个流程
    getFlowByTbale(actualTableName) {
        const url = `/api/epms/CustomProcessDefinitionView.queryOneByActualTableName.query`
        return axiosService.postAction(url, {params: {actualTableName}})
    },
    // 定义流程
    defineFlow(data) {
        const url = `/api/epms/ProcessDefinitionTransactor.createDeploymentByString.command`
        return axiosService.postAction(url, {data})
    },
    // 新增流程定义
    saveFlow(data) {
        let url = `/api/epms/CustomProcessDefinitionTransactor.create.command`
        if (data.id) url = `/api/epms/CustomProcessDefinitionTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 修改流程定义
    updateFlow(data) {
        const url = `/api/epms/CustomProcessDefinitionTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 删除
    deleteFlow(pdID) {
        const url = `/api/epms/ProcessDefinitionTransactor.delDefinition.command`
        return axiosService.postAction(url, {
            data: {pdID},
        })
    },
    // 获取日志
    getLog(params) {
        const url = `/api/log/LogView.queryAll.query`
        return axiosService.postAction(url, params)
    },
    // 新增自定义接口
    addApiTransactor(data) {
        const url = `/api/epms/CustomApiTransactor.create.command`
        return axiosService.postAction(url, {data})
    },
    // 编辑自定义接口
    editApiTransactor(data) {
        const url = `/api/epms/CustomApiTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 删除自定义接口
    deleteApiTransactor(data) {
        const url = `/api/epms/CustomApiTransactor.delete.command`
        return axiosService.postAction(url, data)
    },
    // 获取接口列表
    executeScript(params) {
        const url = `/api/epms/execute-script`
        return axiosService.postAction(url, params)
    },
    // +----------------------------------------------------------------------------------------------
    // | 增强接口
    // +----------------------------------------------------------------------------------------------
    getApiTransactorList(params) {
        const url = `/api/epms/CustomApiView.queryAll.query`
        params = {
            ...params,
            ignoreFieldList: ['creationOperatorSnapshot', 'updateOperatorSnapshot', 'receiveUserSnapshot'],
        }
        return axiosService.postAction(url, params)
    },
    queryDefaultJsFunctionsInstruction(params) {
        const url = `/api/epms/defaultJsFunctions`
        return axiosService.postAction(url, params)
    },
    // 沙盒测试
    sandbox(params) {
        const url = `/api/epms/run-js-in-sandbox`
        return axiosService.postAction(url, params)
    },
    // +----------------------------------------------------------------------------------------------
    // | ETL 表单同步修改
    // +----------------------------------------------------------------------------------------------
    // 查询列表
    getETLList(params) {
        const url = `/api/epms/ExtractTransformLoadView.queryAll.query`
        return axiosService.postAction(url, params)
    },
    // 新增ETL
    addETLForm(params) {
        const url = `/api/epms/ExtractTransformLoadTransactor.create.command`
        return axiosService.postAction(url, params)
    },
    // 修改ETL
    updateETLForm(params) {
        const url = `/api/epms/ExtractTransformLoadTransactor.update.command`
        return axiosService.postAction(url, params)
    },
    // 删除ETL
    deleteETLForm(params) {
        const url = `/api/epms/ExtractTransformLoadTransactor.delete.command`
        return axiosService.postAction(url, params)
    },
    // 获取表单数据
    getFormList(params) {
        const url = `/api/epms/FormView.queryAll.query`
        params = {
            ...params,
            ignoreFieldList: ['creationOperatorSnapshot', 'updateOperatorSnapshot', 'receiveUserSnapshot'],
        }
        return axiosService.postAction(url, params)
    },
    // +----------------------------------------------------------------------------------------------
    // | 发送消息
    // +----------------------------------------------------------------------------------------------
    // 消息列表
    getMessageList(params) {
        const url = `/api/message/MessageTemplateView.queryAll.query`
        return axiosService.postAction(url, params)
    },
    // 根据id查询单个消息信息
    getMessageById(params) {
        const url = `/api/message/MessageTemplateView.queryOne.query`
        return axiosService.postAction(url, params)
    },
    // 发送消息
    sendMessage(params) {
        const url = `/api/message/MessageTemplateTransactor.create.command`
        return axiosService.postAction(url, params)
    },
    // 编辑消息
    updateMessage(params) {
        const url = `/api/message/MessageTemplateTransactor.update.command`
        return axiosService.postAction(url, params)
    },
    // 删除消息
    deleteMessage(params) {
        const url = `/api/message/MessageTemplateTransactor.delete.command`
        return axiosService.postAction(url, params)
    },
    // +----------------------------------------------------------------------------------------------
    // | 我的消息
    // +----------------------------------------------------------------------------------------------
    // 我的消息列表
    getMyMessageList(params) {
        const url = `/api/message/MessageView.queryMy.query`
        params = {
            ...params,
            ignoreFieldList: ['creationOperatorSnapshot', 'receiveUserSnapshot'],
        }
        return axiosService.postAction(url, params, {
            headers: {AutoAccess: 'Yes'},
        })
    },
    // 根据id查询单个消息信息
    getMyMessageById(params) {
        const url = `/api/message/MessageView.queryOne.query`
        return axiosService.postAction(url, params)
    },
    // 标记已读（数组：单个/多个）
    setMessageRead(params) {
        const url = `/api/message/MessageTransactor.readAll.command`
        return axiosService.postAction(url, params)
    },
    // +----------------------------------------------------------------------------------------------
    // | 运营配置
    // +----------------------------------------------------------------------------------------------
    addConfig(data) {
        const url = `/api/config/ConfigTransactor.create.command`
        return axiosService.postAction(url, {data})
    },
    editConfig(data) {
        const url = `/api/config/ConfigTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    getConfig(params) {
        const url = `/api/config/ConfigView.queryAll.query`
        return axiosService.postAction(url, params)
    },
    deleteConfig(id) {
        const url = `/api/config/ConfigTransactor.delete.command`
        return axiosService.postAction(url, {
            data: {id},
        })
    },
    // +----------------------------------------------------------------------------------------------
    // | token管理
    // +----------------------------------------------------------------------------------------------
    getTokenList(params) {
        const url = `/api/user/TokenView.queryAll.query`
        return axiosService.postAction(url, params)
    },
    addToken(data) {
        const url = `/api/user/TokenTransactor.create.command`
        return axiosService.postAction(url, {data})
    },
    editToken(data) {
        const url = `/api/user/TokenTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    deleteToken(id) {
        const url = `/api/user/TokenTransactor.delete.command`
        return axiosService.postAction(url, {data: {id}})
    },
    // 导入导出
    exportOut() {
        const url = `/api/epms/ApplicationView.exportApp.query`
        return axiosService.postAction(url, {})
    },
    exportOutApp(data) {
        const url = `/api/epms/ApplicationView.exportAppById.query`
        return axiosService.postAction(url, data)
    },
    uploadApp(data) {
        const url = `/api/epms/TenantApplicationTransactor.importApp.command`
        return axiosService.postAction(url, data)
    },
    upLoad(json) {
        const url = `/api/epms/ApplicationTransactor.importApp.command`
        return axiosService.postAction(url, {data: json})
    },
    // 加密
    encrypt(data) {
        const url = `/api/epms/RsaTransactor.encrypt.command`
        return axiosService.postAction(url, {data})
    },
    // 解密
    decrypt(data) {
        const url = `/api/epms/RsaTransactor.decrypt.command`
        return axiosService.postAction(url, {data})
    },
    // 复制应用
    copyApplication(data) {
        const url = `/api/epms/ApplicationTransactor.copy.command`
        return axiosService.postAction(url, {data})
    },
    copyForm(data) {
        const url = `/api/epms/FormTransactor.copyForm.command`
        return axiosService.postAction(url, {data})
    },
    uploadFormList(data) {
        let url = `/api/form/FormDynamicTransactor.createBatch.command`
        if (data.data.tableCode) {
            url += `?tableCode=${data.data.tableCode}`
        }
        return axiosService.postAction(url, {data})
    },
    // 获取其他表单下拉选项
    getSelectData(params) {
        const url = `/api/epms/FormView.queryAllForTree.query`
        return axiosService.postAction(url, {params})
    },
    // 新的保存应用权限接口
    saveAuthUI(data) {
        const url = `/api/user/RoleTransactor.batchSaveAuthUi.command`
        return axiosService.postAction(url, data)
    },
    // 上传文件
    uploadToMinio(data) {
        const url = `/api/file/upload`
        return axiosService.postAction(url, data)
    },
    // 用户授权自定义API
    userTransactor(data) {
        const url = `/api/user/UserTransactor.grantRoleAuthorityApiIds.command`
        return axiosService.postAction(url, data)
    },
    // 角色授权自定义API
    roleTransactor(data) {
        const url = `/api/user/RoleTransactor.grantRoleAuthorityApiIds.command`
        return axiosService.postAction(url, data)
    },
    // debug自定义增强
    async debug(script) {
        const url = `/api/epms/biz/front-script`
        const res = await axiosService.postAction(url, {script})
        return JSON.parse(JSON.stringify(res))
    },
    // 应用下的菜单管理
    getAppMenuForSetting(data) {
        const url = `/api/epms/MenuView.queryAll.query`
        data = {
            ...data,
            ignoreFieldList: ['creationOperatorSnapshot', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, data)
    },
    saveAppMenu(data) {
        let url = `/api/epms/MenuTransactor.create.command`
        if (data.id) url = `/api/epms/MenuTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    deleteAppMenu(id) {
        const url = `/api/epms/MenuTransactor.delete.command`
        return axiosService.postAction(url, {
            data: {id},
        })
    },
    // 流程设计
    // 列表
    getCustomProcessList(data) {
        const url = `/api/epms/CustomProcessDefinitionView.queryAll.query`
        data = {
            ...data,
            ignoreFieldList: ['creationOperatorSnapshot', 'customProcessNodeDataList', 'updateOperatorSnapshot'],
        }
        return axiosService.postAction(url, data)
    },
    getMineCustomProcessList(data) {
        const url = `/api/epms/CustomProcessDefinitionView.queryMine.query`
        return axiosService.postAction(url, data)
    },
    getCustomProcessOne(data) {
        const url = `/api/epms/CustomProcessDefinitionView.queryOne.query`
        return axiosService.postAction(url, data)
    },
    saveCustomProcess(data) {
        let url = `/api/epms/CustomProcessDefinitionTransactor.create.command`
        if (data.id) url = `/api/epms/CustomProcessDefinitionTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    deleteCustomProcess(id) {
        const url = `/api/epms/CustomProcessDefinitionTransactor.delete.command`
        return axiosService.postAction(url, {
            data: {id},
        })
    },
    // 流程实例
    queryProcessAll(data) {
        // const url = `/api/epms/ProcessInstanceView.queryProcessAll.query`
        const url = `/api/epms/CustomProcessInstanceView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    queryProcessAllForProcessManage(data) {
        // const url = `/api/epms/ProcessInstanceView.queryProcessAll.query`
        const url = `/api/epms/CustomProcessInstanceView.queryAllForProcessManage.query`
        return axiosService.postAction(url, data)
    },
    // 历史流程
    getProcessHistoryList(data) {
        const url = `/api/epms/ProcessInstanceView.queryHistoryAll.query`
        return axiosService.postAction(url, data)
    },
    // 挂起流程
    suspendInstance(data) {
        // const url = `/api/epms/ProcessInstanceTransactor.suspendInstance.command`
        const url = `/api/epms/CustomProcessInstanceTransactor.suspendProcess.command`
        return axiosService.postAction(url, {data})
    },
    // 激活流程
    resumeInstance(data) {
        // const url = `/api/epms/ProcessInstanceTransactor.resumeInstance.command`
        const url = `/api/epms/CustomProcessInstanceTransactor.resumeProcess.command`
        return axiosService.postAction(url, {data})
    },
    // 关闭流程
    deleteInstance(data) {
        // const url = `/api/epms/ProcessInstanceTransactor.deleteInstance.command`
        const url = `/api/epms/CustomProcessInstanceTransactor.deleteProcess.command`
        return axiosService.postAction(url, {data})
    },
    // 委派流程
    delegateTask(data) {
        const url = `/api/epms/TaskTransactor.delegateTask.command`
        return axiosService.postAction(url, {data})
    },
    // 历史任务
    getHistoryTask(data) {
        const url = `/api/epms/TaskView.queryHistoryTask.query`
        return axiosService.postAction(url, data)
    },
    // 获取表格行数据
    getFormDynamicOne(data) {
        // const url = `/api/form/FormDynamicView.queryOneById.query`
        let url = `/api/form/FormDynamicView.queryOne.query`
        if (data.params.tableCode) {
            url += `?tableCode=${data.params.tableCode}`
        }
        return axiosService.postAction(url, data)
    },
    // 任务处理
    queryHistoryTaskAll(data) {
        const url = `/api/epms/TaskView.queryHistoryTaskAll.query`
        return axiosService.postAction(url, data)
    },
    queryActivityStatus(data) {
        const url = `/api/epms/TaskView.queryActivityStatus.query`
        return axiosService.postAction(url, data)
    },
    getCustomProcessInstanceNode(data) {
        const url = `/api/epms/CustomProcessInstanceNodeView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // getCustomProcessNode(data) {
    //   const url = `/api/epms/CustomProcessNodeView.queryOne.query`
    //   return axiosService.postAction(url, data)
    // },
    // 修改流程节点
    saveCustomProcessNode(data) {
        const url = `/api/epms/CustomProcessNodeTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 查询单个流程定义(根据id)
    getCustomProcessDefinition(data) {
        const url = `/api/epms/CustomProcessDefinitionView.queryOne.query`
        return axiosService.postAction(url, data)
    },
    saveCustomProcessDefinition(data) {
        const url = `/api/epms/CustomProcessDefinitionTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 帮助文档
    getHelpDoc(data) {
        const url = `/api/epms/HelpView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    saveHelpDoc(data) {
        let url = `/api/epms/HelpTransactor.create.command`
        if (data.id) url = `/api/epms/HelpTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 帮助文档管理
    getDocList(data) {
        const url = `/api/epms/CustomHelpView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    addDoc(data) {
        let url = `/api/epms/CustomHelpTransactor.create.command`
        if (data.id) url = `/api/epms/CustomHelpTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    delDoc(data) {
        const url = `/api/epms/CustomHelpTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    // 获取流程历史追踪
    queryHistoryActivityTaskAll(data) {
        const url = `/api/epms/TaskView.queryHistoryActivityTaskAll.query`
        return axiosService.postAction(url, data)
    },
    // 提交流程
    startProcess(data) {
        const url = `/api/epms/ProcessInstanceTransactor.startProcess.command`
        return axiosService.postAction(url, {data})
    },
    // 保存流程
    saveProcess(data) {
        const url = `/api/epms/CustomProcessInstanceTransactor.createProcess.command`
        return axiosService.postAction(url, {data})
    },
    // 作废流程
    cancelProcess(data) {
        const url = `/api/epms/TaskTransactor.cancelTask.command`
        return axiosService.postAction(url, {data})
    },
    // 撤回流程
    revokeProcess(data) {
        const url = `/api/epms/TaskTransactor.revokeTask.command`
        return axiosService.postAction(url, {data})
    },
    // 驳回流程
    rejectProcess(data) {
        const url = `/api/epms/TaskTransactor.rejectTask.command`
        return axiosService.postAction(url, {data})
    },
    // 提交退回的任务
    updateProcessInstance(data) {
        const url = `/api/epms/CustomProcessInstanceTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 驳回目标节点列表
    queryTargetRejectTaskList(data) {
        const url = `/api/epms/TaskView.queryTargetRejectTaskList.query`
        return axiosService.postAction(url, data)
    },
    // 驳回目标节点列表(优化)
    queryRevokeTargetTaskList(data) {
        const url = `/api/epms/TaskView.queryRevokeTargetTaskList.query`
        return axiosService.postAction(url, data)
    },
    // 已审批历史列表-详细详细
    getCustomProcessInstanceHistory(data) {
        const url = `/api/epms/CustomProcessInstanceView.queryHistory.query`
        return axiosService.postAction(url, data)
    },
    // 已审批列表
    queryAlreadyApprove(data) {
        const url = `/api/epms/CustomProcessInstanceView.queryAlreadyApprove.query`
        return axiosService.postAction(url, data)
    },
    // 查已审批列表下任务拥有的表单字段
    queryAlreadyApproveFormField(data) {
        const url = `/api/epms/CustomProcessInstanceView.queryAlreadyApproveFormField.query`
        return axiosService.postAction(url, data)
    },
    // 待发布
    getPendingPublishList(data) {
        const url = `/api/epms/TaskView.queryPendingPublish.query`
        return axiosService.postAction(url, data)
    },
    // 已退回
    getReturnAndRejectList(data) {
        const url = `/api/epms/TaskView.queryReturnAndReject.query`
        return axiosService.postAction(url, data)
    },
    // 待办
    // 待审批
    getPendingApprovalList(data) {
        const url = `/api/epms/TaskView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 已审批
    getAlreadyApproveList(data) {
        const url = `/api/epms/TaskView.queryAlreadyApprove.query`
        return axiosService.postAction(url, data)
    },
    // 我发起的
    getStartApproveList(data) {
        const url = `/api/epms/TaskView.queryStartApprove.query`
        return axiosService.postAction(url, data)
    },
    // 抄送我的
    getCarbonCopyTaskList(data) {
        const url = `/api/epms/TaskView.queryCarbonCopyTaskAll.query`
        return axiosService.postAction(url, data)
    },
    // 流程部署
    deployProcessDefinition(data) {
        const url = `/api/epms/ProcessDefinitionTransactor.createDeploymentByString.command`
        return axiosService.postAction(url, {data})
    },
    completeTask(data) {
        const url = `/api/epms/TaskTransactor.completeTask.command`
        return axiosService.postAction(url, {data})
    },
    // 工作台我的工作统计
    getTaskTotal(data) {
        const url = `/api/epms/TaskView.queryMyTotal.query`
        return axiosService.postAction(url, data)
    },
    // 获取唯一编码
    // @params:{"params":{
    // "codeType":"None(无任何类型)，Uuid(Uuid),Timestamp(时间戳),TimestampOfDay(yyyyMMdd),TimestampDayTime(yyyyMMddHHmmss),TimestampDayTimeMillisecond(yyyyMMddHHmmssSSS)" ,
    // "prefix":"前置编码",
    // "separator":"分隔符（—）"}}
    getCodeByService(data) {
        const url = `/api/epms/CodingView.getCode.query`
        return axiosService.postAction(url, data)
    },
    claimTask(data) {
        const url = `/api/epms/TaskTransactor.claimTask.command`
        return axiosService.postAction(url, {data})
    },
    // +----------------------------------------------------------------------------------------------
    // | 通用字典配置
    // +----------------------------------------------------------------------------------------------
    // 字典主表查询
    getSystemDict(data) {
        const url = `/api/epms/SystemDictView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 字典主表创建
    saveSystemDict(data) {
        let url = `/api/epms/SystemDictTransactor.create.command`
        if (data.id) url = `/api/epms/SystemDictTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    deleteSystemDict(data) {
        const url = `/api/epms/SystemDictTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    // 字典子表查询
    getSystemDictItem(data) {
        const url = `/api/epms/SystemDictItemView.queryAllByDict.query` // `/api/epms/SystemDictItemView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 字典子表创建
    saveSystemDictItem(data) {
        let url = `/api/epms/SystemDictItemTransactor.create.command`
        if (data.id) url = `/api/epms/SystemDictItemTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    deleteSystemDictItem(data) {
        const url = `/api/epms/SystemDictItemTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    // 修改字典状态
    changeSystemDictItemStatus(data) {
        const url = `/api/epms/SystemDictItemTransactor.updateUseStatus.command`
        return axiosService.postAction(url, {data})
    },
    // +----------------------------------------------------------------------------------------------
    // | 导出模板管理
    // +----------------------------------------------------------------------------------------------
    getExportTemplates(data) {
        const url = `/api/epms/ExportTemplateView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 导出模板创建
    saveExportTemplate(data) {
        let url = `/api/epms/ExportTemplateTransactor.create.command`
        if (data.id) url = `/api/epms/ExportTemplateTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 导出模板删除
    delExportTemplate(id) {
        const url = `/api/epms/ExportTemplateTransactor.delete.command`
        return axiosService.postAction(url, {data: {id}})
    },

    // +----------------------------------------------------------------------------------------------
    // | 导入模板管理
    // +----------------------------------------------------------------------------------------------
    getImportTemplates(data) {
        const url = `/api/epms/ImportTemplateView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 导出模板创建
    saveImportTemplate(data) {
        let url = `/api/epms/ImportTemplateTransactor.create.command`
        if (data.id) url = `/api/epms/ImportTemplateTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 导出模板删除
    delImportTemplate(id) {
        const url = `/api/epms/ImportTemplateTransactor.delete.command`
        return axiosService.postAction(url, {data: {id}})
    },
    downloadFile(filename, downloadUrl) {
        // 此为下载上传组件
        const params = {
            encodeRename: filename,
            encodeUrl: downloadUrl,
        }
        console.log(params)
        return axiosService.downloadAction(qs.stringify(params))
    },
    exportFile(filename, data) {
        const url = `/api/epms/commonExport`
        return axiosService.postAction(url, data, {
            responseType: 'blob',
            headers: {
                filename: encodeURIComponent(filename),
            },
        })
    },
    // +----------------------------------------------------------------------------------------------
    getCustomProcessInstanceByDataId(data) {
        const url = `/api/epms/CustomProcessInstanceView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    queryHistoryByDataId(data) {
        const url = `/api/epms/CustomProcessInstanceView.queryHistory.query`
        return axiosService.postAction(url, data)
    },
    // DataAuthCodeDictView.queryAll.query"
    // 数据权限码字典查询
    getDataAuthCodeDictView(data) {
        const url = `/api/user/DataAuthCodeView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 数据权限码创建
    saveDataAuthCodeDict(data) {
        let url = `/api/user/DataAuthCodeTransactor.create.command`
        if (data.id) url = `/api/user/DataAuthCodeTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 数据权限码删除
    deleteDataAuthCodeDict(data) {
        const url = `/api/user/DataAuthCodeTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    // 数据权限码字典子表查询
    getDataAuthCodeDictItems(data) {
        const url = `/api/user/DataAuthCodeDictView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 数据权限码字典子表创建
    saveDataAuthCodeDictItem(data) {
        let url = `/api/user/DataAuthCodeDictTransactor.create.command`
        if (data.id) url = `/api/user/DataAuthCodeDictTransactor.update.command`
        return axiosService.postAction(url, {data})
    },
    // 数据权限码字典子表删除
    deleteDataAuthCodeDictItem(data) {
        const url = `/api/user/DataAuthCodeDictTransactor.delete.command`
        return axiosService.postAction(url, {data})
    },
    // 登录后查询用户数据权限
    getDataAuthCodeDictByUser(data) {
        const url = `/api/user/DataAuthCodeView.queryDataCode.query`
        return axiosService.postAction(url, data)
    },
    // 获取配置
    getConfigList(params) {
        const url = `/api/config/ConfigView.queryAll.query`
        return axiosService.postAction(url, params)
    },
    // 流程历史查看日志
    getProcessLogList(data) {
        const url = `/api/epms/ProcessLogView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 查看日志
    getViewLog(data) {
        const url = `/api/epms/CustomApiLogView.queryAll.query`
        return axiosService.postAction(url, {data})
    },
    getSystemHelpView(data) {
        const url = `/api/epms/SystemHelpView.queryAll.query`
        return axiosService.postAction(url, data)
    },
    // 查流程实例下全部历史任务、任务节点定义、当前任务
    queryMergeTasks(params) {
        const url = `/api/epms/TaskView.queryMergeTasks.query`
        return axiosService.postAction(url, params)
    },
    // 采购待办
    // procurementPendingList(data) {
    //   const url = `/api/form/FormDynamicView.queryAll.query`
    //   return axiosService.postAction(url, data)
    // },
    // // 增加
    // addProcurementPending(data) {
    //   const url = `/api/form/FormDynamicTransactor.create.command`
    //   return axiosService.postAction(url, data)
    // },
    // // 删除
    // deleteProcurementPending(data) {
    //   const url = `/api/form/FormDynamicTransactor.delete.command`
    //   return axiosService.postAction(url, data)
    // },
    // // 编辑
    // editProcurementPending(data) {
    //   const url = `/api/form/FormDynamicTransactor.update.command`
    //   return axiosService.postAction(url, data)
    // }
}
export default $apiService
